package com.bosssoft.trainee.mbg.vo;

import com.bosssoft.trainee.mbg.util.validator.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @Author: wuxin
 * @Date: 2022/6/21
 * @Project: rbac
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResourceVO {
    private Integer id;
    @NotBlank(message = "资源名不能为空")
    @Length(max = 6,message = "资源名长度不得多于6个字符")
    @Pattern(regexp = "^((?![!'@#$%^&*()<>{}\\[\\]|\\\\+_=\\-:\";,.?/`~]).){1,6}$",message = "资源名称不能包含特殊字符")
    private String name;
    @NotBlank(message = "不能为空")
    @Length(max = 10,message = "资源url长度不得多于10个字符")
    @Pattern(regexp = "^((?=[a-zA-Z/]).){1,10}$",message = "格式不正确")
    private String url;
    @NotBlank(message = "不能为空")
    @Length(max = 10,message = "资源api长度不得多于10个字符")
    @Pattern(regexp = "^((?=[a-zA-Z/]).){1,10}$",message = "格式不正确")
    private String api;
    @NotBlank(message = "资源代码不能为空")
    @Pattern(regexp = "^\\d{4}$",message = "格式不正确")
    private String code;
    @NotBlank(message = "请求方式不能为空")
    @EnumValue(strValues = {"GET", "POST", "HEAD", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"},message = "请求方式未知")
    private String method;
    @NotBlank(message = "打开图标不能为空")
    private String openIcon;
    @NotBlank(message = "关闭图标不能为空")
    private String closeIcon;
    private Integer parentId;
    @NotNull(message = "状态不能为空")
    private Integer state;
}
